<extend name="desktop_default/template/user/base_user" />
<block name="area_header">
    <link rel="stylesheet" href="__CSS__/user/setpsw/style.css">
</block>

<block name="area_top">

</block>
<block name="user_top">

</block>
<block name="main_content">
    <div class="setpsw">
        <div class="user-tab">
            <a class="selected" href="javascript:void(0);">修改密码</a>
        </div>
        <empty name="result">
            <div class="setpsw-form">
                <form name="setpsw" action="__SELF__" method="post">
                    <div class="form-group">
                        <div class="l">
                            <label for="psw">当前密码*</label>
                        </div>
                        <div class="r">
                            <input id="psw" type="password" name="psw">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="l">
                            <label for="new_psw">新密码*</label>
                        </div>
                        <div class="r">
                            <input id="new_psw" type="password" name="new_psw">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="l">
                            <label for="confirm_psw">确认新密码*</label>
                        </div>
                        <div class="r">
                            <input id="confirm_psw" type="password" name="confirm_psw">
                        </div>
                    </div>
                    <div class="form-group">
                        <a class="btn save" href="javascript:void(0);">保存</a>
                    </div>
                </form>
            </div>
        </empty>
        <notempty name="result">
            <div class="result">
                <h2>{$result}</h2>
                <a class="btn btn-back" href="{:U('mengwu/user/setpsw')}">返回</a>
            </div>
        </notempty>


    </div>

</block>
<block name="area_footer">
    <script type="text/javascript">
        var showTip = function($ele,tip){
            $(".form-group .tip").remove();
            $ele.focus();
            $ele.parent().parent().append('<div class="tip">*'+tip+'</div>');
        };
        $(".save").click(function(){
            var $psw = $("#psw");
            var $new_psw = $("#new_psw");
            var $confirm_psw = $("#confirm_psw");
            if($psw.val().length==0){
                showTip($psw,'旧密码不能为空');
                return;
            }
            if($new_psw.val().length<6){
                showTip($new_psw,'新密码长度不能小于6位');
                return;
            }
            if($new_psw.val()==$psw){
                showTip($new_psw,'新密码不能与旧密码相同');
                return;
            }
            if($new_psw.val()!=$confirm_psw.val()){
                showTip($confirm_psw,'2次新密码必须一致');
                return;
            }
            setpsw.submit();

        });
    </script>
</block>
